<template>

    <div>
        <van-row>
            <van-col span="24">
                <van-icon id="fanhui" @click="tuichu()" name="cross" />
            </van-col>
        </van-row>
    </div>
    <div>
        <h1>支付宝支付</h1>
        <h2>订单名称：{{name}}</h2>
        <h2>金额：{{money}} 元</h2>
        <div><van-button @click="sendPay()">确认支付</van-button></div>
    </div>
</template>

<script>
    export default {
        name: "Pay",
        data(){
            return{
                money:0,
                name:"",
                count:0,
                id:0
            }
        },
        methods:{
            sendPay(){
                var that = this
                //发起创建支付请求
                var obj={
                    money: that.money,
                    oid: 1,
                    title: that.name,
                    type: 1
                }
                this.axios.post("http://localhost:8888/api/pay/create.do",obj).then(res=>{
                    if(res.data.code==200){
                        //成功
                        document.write("'"+res.data.data+"'");
                    }else{

                    }
                })

                this.axios.post("http://localhost:8081/api/shopping/detail.do",{
                    "id":that.id,
                    "shoppingcount":that.count
                })
                    .then(function (res) {
                        if (res.data.code==200){
                            Toast("付款成功")
                        }
                    })
            },
            tuichu(){
                history.back();
            }
        },
        mounted(){
            var money=this.$route.query.money
            var name=this.$route.query.name
            var count=this.$route.query.count
            var id=this.$route.query.count.id

            this.money=money
            this.name=name
            this.count=count
            this.id=id
        }
    }
</script>

<style scoped>

</style>